#ifndef APPMANAGER_H
#define APPMANAGER_H

#include <QtGui>
#include "commons.h"

class AppManager : public QObject
{
    Q_OBJECT
public:
    enum CursorType {
        NORMAL,
        CROSS,
        LINER,
        HANDER,
        PICKER,
        GRABBER
    };

    enum SelectType {
        PLAY,
        LOAD,
        DEFAULT
    };

    enum SceneType {
        MENU,
        EDITOR,
        SELECTOR,
        PLAYGROUND
    };

    explicit AppManager(QObject *parent = 0);
    ~AppManager();
    void start();

signals:

private slots:
    // Prefix `g': Global
    // Prefix `e': Editor
    // Prefix `m': Main menu
    // Prefix `p': Playground
    void gShowMainMenu();
    void gExitApp();
    void gChangeCursorNormal();
    void gChangeCursorCross();
    void gChangeCursorLiner();
    void gChangeCursorGrabber();
    void gChangeCursorPicker();
    void gChangeCursorHander();
    void gSelectLevel(int id);
    void mEditorClicked();
    void mLevelClicked();
//    void mAboutClicked();
    void eLineClicked();
    void ePointClicked();
    void eChangeCursorWhenEntering(CanvasState state);
    void eSaveLevel(const QString&);
    void eLoadLevel();
    void pNextLevel();

private:
    void initResources();
    void initScene();
    void initEventSystem();
    void changeCursor(CursorType type);
    void changeScene(SceneType type);

    SelectType selectType;

    QSize minWindowSize;
    QCursor normalCursor;
    QCursor linerCursor;
    QCursor crossCursor;
    QCursor pickerCursor;
    QCursor grabberCursor;
    QCursor handerCursor;

    QGraphicsView *mainWindow;
    QGraphicsScene *mainMenuScene;
    QGraphicsScene *editorScene;
    QGraphicsScene *selectorScene;
    QGraphicsScene *playgroundScene;

    MainMenu *mainMenu;
    LevelEditor *levelEditor;
    LevelBrowser *levelBrowser;
    LevelManager *levelManager;
    Playground *playground;

};

#endif // APPMANAGER_H
